home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 11604 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.6 KB

  1. Path: mail2news.demon.co.uk!genesis.demon.co.uk
  2. From: Lawrence Kirby <fred@genesis.demon.co.uk>
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Determining the length of an int in string form
  5. Date: Mon, 25 Mar 96 12:48:09 GMT
  6. Organization: none
  7. Message-ID: <827758089snz@genesis.demon.co.uk>
  8. References: <3146D058.DD7@cbm.com> <4i7uth$qph@inet-nntp-gw-1.us.oracle.com> <DoE38u.GIH@iquest.net> <4in1ga$ogk@airdmhor.gen.nz> <Pine.SOL.3.91.960319172332.4535A-100000@darwin.UCSC.EDU> <314F65D3.6A8@oc.com> <827703345snz@genesis.demon.co.uk> <3155E067.3261@iadfw.net>
  9. Reply-To: fred@genesis.demon.co.uk
  10. X-NNTP-Posting-Host: genesis.demon.co.uk
  11. X-Newsreader: Demon Internet Simple News v1.27
  12. X-Mail2News-Path: genesis.demon.co.uk
  13.  
  14. In article <3155E067.3261@iadfw.net> lfw@iadfw.net "Larry Weiss" writes:
  15.  
  16. >We all discussed this, maybe a year ago, and what I was remembering was
  17. >the issue with the representation of end-of-line on the file system, and
  18. >whether this affected the return value of fprintf().
  19.  
  20. 7.9.3:
  21.  
  22. "All input takes place as if characters were read by successive calls to
  23. the fgetc function; all output takes place as if characters were written
  24. by successive calls to the fputc function."
  25.  
  26. The only figure with any meaning is the number of effective calls to fputc.
  27. Once you start getting into the lower level text file line formatting C
  28. ceases to ascribe any meaningful values to 'characters transferred'. So
  29. IMHO the return value of fprintf can only refer to the number of effective
  30. fputc calls which means '\n' always corresponds to precisely 1 character.
  31.  
  32. >Seems safe enough
  33. >that if you never indicate the end-of-line condition (usually via the
  34. >\n in in format string) then that is not an issue (even on a mainframe,
  35. >with those block-mode fixed-length records).    
  36.  
  37. The problem there is that in block-mode fixed-length records you may well
  38. get *no* characters written until the whole block is assembled (i.e. you
  39. wrote a '\n'). Perhaps a more obvious format to show this is a variable
  40. length block with the block length written at the start: nothing can be
  41. written until the block length is known.
  42.  
  43. >Now what I'd really like to see in the next revision of the standard library
  44. >would be an snprintf() with the extra argument to declare only so many
  45. > writeable
  46. >chars in the buffer, and a return code to indicate logical attempts to write
  47. >beyond that limit.
  48.  
  49. Indeed, a return value indicating how many characters would have been
  50. written to the buffer if it were large enough.
  51.  
  52. -- 
  53. -----------------------------------------
  54. Lawrence Kirby | fred@genesis.demon.co.uk
  55. Wilts, England | 70734.126@compuserve.com
  56. -----------------------------------------
  57.